package com.ruoyi.web.controller.emergency;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.emergency.domain.EpEscapeRouteConfig;
import com.ruoyi.emergency.service.IEpEscapeRouteConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 避灾路线配置Controller
 * 
 * @author hcc
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/control/routeConfig")
public class EpEscapeRouteConfigController extends BaseController
{
    @Autowired
    private IEpEscapeRouteConfigService epEscapeRouteConfigService;

    /**
     * 查询避灾路线配置列表
     */
    @PreAuthorize("@ss.hasPermi('control:routeConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(EpEscapeRouteConfig epEscapeRouteConfig)
    {
        startPage();
        List<EpEscapeRouteConfig> list = epEscapeRouteConfigService.selectEpEscapeRouteConfigList(epEscapeRouteConfig);
        return getDataTable(list);
    }

    /**
     * 导出避灾路线配置列表
     */
    @PreAuthorize("@ss.hasPermi('control:routeConfig:export')")
    @Log(title = "避灾路线配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EpEscapeRouteConfig epEscapeRouteConfig)
    {
        List<EpEscapeRouteConfig> list = epEscapeRouteConfigService.selectEpEscapeRouteConfigList(epEscapeRouteConfig);
        ExcelUtil<EpEscapeRouteConfig> util = new ExcelUtil<EpEscapeRouteConfig>(EpEscapeRouteConfig.class);
        util.exportExcel(response, list, "避灾路线配置数据");
    }

    /**
     * 获取避灾路线配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:routeConfig:query')")
    @GetMapping(value = "/{routeConfigId}")
    public AjaxResult getInfo(@PathVariable("routeConfigId") String routeConfigId)
    {
        return success(epEscapeRouteConfigService.selectEpEscapeRouteConfigByRouteConfigId(routeConfigId));
    }

    /**
     * 新增避灾路线配置
     */
    @PreAuthorize("@ss.hasPermi('control:routeConfig:add')")
    @Log(title = "避灾路线配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EpEscapeRouteConfig epEscapeRouteConfig)
    {
        return toAjax(epEscapeRouteConfigService.insertEpEscapeRouteConfig(epEscapeRouteConfig));
    }

    /**
     * 修改避灾路线配置
     */
    @PreAuthorize("@ss.hasPermi('control:routeConfig:edit')")
    @Log(title = "避灾路线配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EpEscapeRouteConfig epEscapeRouteConfig)
    {
        return toAjax(epEscapeRouteConfigService.updateEpEscapeRouteConfig(epEscapeRouteConfig));
    }

    /**
     * 删除避灾路线配置
     */
    @PreAuthorize("@ss.hasPermi('control:routeConfig:remove')")
    @Log(title = "避灾路线配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{routeConfigIds}")
    public AjaxResult remove(@PathVariable String[] routeConfigIds)
    {
        return toAjax(epEscapeRouteConfigService.deleteEpEscapeRouteConfigByRouteConfigIds(routeConfigIds));
    }
}
